<template>
  <div class="swiper">
    <swipe :autoplay="3000" indicator-color="white">
      <swipe-item v-for="(item, index) in banners" :key="index">
        <a :href="item.link">
          <img :src="item.image" @load="imgloaed" />
        </a>
      </swipe-item>
    </swipe>
  </div>

</template>

<script scoped>
import { Swipe, SwipeItem } from 'vant';
export default {
  name: 'HomeSwiper',
  props: {
    banners: {
      type: Array,
      default: []
    }
  },
  data() {
    return {
      isLoaded: false
    }
  },
  components: {
    Swipe,
    SwipeItem
  },
  methods: {
    imgloaed() {
      if(!this.isLoaded){
        this.$emit('imgLoaded')
      }
    }
  }
}
</script>

<style lang='less' scoped>
.swiper {
  img {
    width: 100vw;
  }
}

</style>
